import React, { Component } from 'react';
import {AtIcon} from "taro-ui";
import {Text, View} from '@tarojs/components'
import './index.scss'

type Props = {
  isCheck?: boolean
  onChange: Function
  value?: string
  disabled?: boolean
}
export default class Check extends Component<Props> {

  constructor(props: Props) {
    super(props);
  }

  Change(check: any) {
    check = !check;
    const {disabled} = this.props;
    if (disabled) return;
    this.props.onChange(check);
  }

  render() {
    const {value, isCheck, disabled} = this.props;
    return (
      <View onClick={this.Change.bind(this, isCheck)} style='display: inline;'>
        <AtIcon value={`icon ${isCheck ? 'icon-kuang-01' : 'icon-kuanghuise-01'}`} customStyle='margin-right: 4px'
          size={14} color={disabled ? '#666' : isCheck ? '#0bbe7f' : ''}
        />
        <Text>{value}</Text>
      </View>
    )
  }
}
